package com.itheima.sh.a_arrayList.arrayList01;

import java.util.ArrayList;

public class a_arrayList_01 {
    public static void main(String[] args) {
        //1.创建集合对象
        ArrayList<String> list = new ArrayList<>();
        //2.添加数据
        list.add("枸杞");
        list.add("Java入门");
        list.add("宁夏枸杞");
        list.add("黑枸杞");
        list.add("人字拖");
        list.add("特级枸杞");
        list.add("枸杞子");
        //3.遍历集合
        for (int i = list.size()-1; i>=0  ; i--) {
            //获取数据
            String s = list.get(i);
            if (s.contains("枸杞")) {
                list.remove(s);
            }
        }
        //4.输出遍历
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }
}